import axios from '@/util/request'
import store from '@/store/index'
/**
 * 获取内容接口
 * @param {*} options 获取内容参数
 */
const getList = (options = {}) => {
  return axios.get('/public/list', {
    params: {
      ...options
    },
    multiple: true
  })
}
// 获取友情链接
const getLinks = () => {
  return axios.get('/public/links')
}
// 获取本周热议
const getTopWeek = () => {
  return axios.get('/public/topWeek')
}
// 获取温馨提醒
const getTips = () => {
  return axios.get('/public/tips')
}

// 上传图片
const upload = (formData) => {
  return axios.post('/content/upload', formData)
}
// 发表帖子
const sendPost = (data) => {
  return axios.post('/content/add', data)
}

// 编辑帖子
const editPost = (data) => {
  return axios.post('/content/edit', data)
}

// 获取详情
const getDetail = (tid) => {
  return axios.get(`public/content/detail/?tid=${tid}`, {
    headers: {
      Authorization: `Bearer ${store.state.token}`
    }
  })
}
export { getList, getLinks, getTopWeek, getTips, upload, sendPost, getDetail, editPost }
